package gov.dhs.cis.soa.data;

import gov.dhs.cis.soa.Constants;
import gov.dhs.cis.soa.Utils;
import gov.dhs.cis.soa.Constants.EntityType;

import java.sql.Timestamp;


public class ComponentModel extends AbstractSOAData {
	public static final String STEREO_TYPE = "Component Model";

	public int id;
	public String name;
	public transient String descText;
	public String stereotype;
	public String wipt;
	public String release;
	public String maturity;
	public String IST;
	
	public Description desc;
	
	public transient Timestamp createdDt = new Timestamp(System.currentTimeMillis());

	@Override
	public String toString() {
		return "ComponentModel [id=" + id + ", name=" + name + "]";
	}
	
	@Override
	public boolean equals(Object obj) {
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ComponentModel other = (ComponentModel) obj;
		if (name.equalsIgnoreCase(other.name) && stereotype.equalsIgnoreCase(other.stereotype) &&
				wipt.equalsIgnoreCase(other.wipt) && release.equalsIgnoreCase(other.release) && 
				maturity == other.maturity)
			return true;
		return false;
	}
	
	public void createDescription() {
		StringBuffer txt = new StringBuffer();
		if(Utils.isEmpty(descText))
			descText = "";
		txt.append(Constants.NL+"Description = " + descText);
		
		desc = Utils.prepareDescObj(txt.toString(), EntityType.COMP);
	}
	
	@Override
	public long getId() {
		return id;
	}
	@Override
	public String getHashableId() {
		return name;
	}
	
	@Override
	public EntityType getUMLType() {
		return EntityType.COMP;
	}
}
